cleaned up comments and added second third function implementation