fix tricky comparison of stage keys issue