fix lots of bug