implement a recursive method