Improved readablity of main loop