refactor the topology