updated code to use latest version of API and improved fake_hive