fix sort of bugs