Add check to ensure object exists before performing action on it