sync the code and fix bug