added comments and corrected all the indents