fix some logical bugs