Completed function body

Completed functions and added comments