fix all kinds of bugs