implementing both required methods
adding comments to the functions