Replace 'defined' check for an 'exists' check