Fixed a bug in condition check