Addded change to check both nil and empty hash.