Fix a bug in position judgement