Thread loop
By @Bel