add commands function and fixed some bug