Added comments and fixed var and function names