fix bug in nextAnimFrame