refactor the whole repo