recursion attempt, works 50%