Fix code format and bug