done a little refactoring