more testing and refactoring