modifying query to return key and value