adding comments, code cleanup