Modified some function names and added comments