Request animation frame for better performance