Worked on functions which also deal with tails