fix minor logical bugs