update and draw loop modified