kvLookup function now handles datatype conversion and fixed originalValue lookup