Some refactor of ordering