refactor the whole structure