Completed both required functions and added comments