made reqAnimFrame code more readable