adapt code to key, value pairs