fixed but in mapping and made script resilient to repeated runs of hive