Tried to write some non iterative version