solve the problem with a times loop