just add some comment and do a little refactor