Fixed the requestAnimFrame function