initial commit, slow recursive implementation