mem limit exceeded due to recursion