convert time from while to for loop
separate methods into separate files