3 squares with different speeds
refactored code