Update new code and fixed some bug