Trying recursive implementation, not really working