Added correct check for variable being defined