little refactoring in code