a little refactoring and cleaning up