a little refactoring here and there