Refactor code constructure