added more code to main loop