refactoring
initial version of region ordering