fix buggy condition