filled in function bodies and added comments