fix: undefined check had incorrect return value