Change functionality to a recursive function

Realized after reviewing with some classmates that it would be more
efficient to refactor this to be a recursive function, rather than a
private function and setInterval.