Make fully recursive and functional