Not working version without recursion.