refactor and reordering