swapped creation of objects out of the main loop