Test and refactoring a bit