fix a lot bugs