Adding comments to all functions
Renaming some function arguments for clarity