refactor code to lose coupling