updated comments and little refacored