refactor all code