Refactoring + requestAnimationFrame instead of setInterval