added comments explaining what each function may be doing