Fix syntax error. Refactor condition