Added some comments for the function implementations