crack at a little refactoring