Committing both the functions
Corrected code and updated comments