Fixing undefined index error when model is not set