a little refuctoring