Check for nil stack id before creating one