fixed collision errors in main loop