change while loop by setTimeout (for animation)