fixed the bug in unit checking