fix a lot of side cases