Completed all functionalities. Added comments