started homework 1, implemented better recursive algorithm