move the idle loop to main.c