Check if variable isset to avoid undefined error