added comments and function bodies