Added comments and trimmed codes