modified for HIVE-4501