added recursion, fixed typos