Fixing undefined check