refactor motor into a separate class