new attempt at recursive solution