fix bug and improvement