finished all functions and added comments