completed functions and added comments