clean up + a little refactoring