adding comments, minor restructure