added support for complext keys using the key function