refactor and reorged