fix query condition bugs