First attempt at recursive solution