further testing and a little refactoring