Worked on the recursive encoding