switched to request animation frame