fix some bug logic