Updating function names
Fixing minor issues - variable name, comments