bug in main loop and changeSub fixed