loop instead of while 1