Added comments and refactored indents