Added comments to functions and checked for proper formatting