some comments, slight refactoring