Separated level code and main loop
Separated level code and main loop