some refactoring for stage support