fix bug of infinite looping by using lastDraw functionality