fix bug and beautifier code