fix bug and tweak length