Simplified the recursive method a little