move duration from seconds to ms
refactor animate method to be cleaner; use requestAnimationFrame