Added comments and formatting