add and remove hosts, refactoring