custom functions to transform keys and values