fixed a bug in unit checking condition