refactoring to remove some duplication, added some error handling to interacting with zookeeper, utility methods for working with zookeeper