Fix on checking side for #6099
Use logical instead of bitwise operators to save cpu