Added function bodies and comments