some refactoring, and text fix for ordering