port over grace
work with either instance index environment variable