Add functions implementations and some comments

This was programming assignment, the assignment was implement functions