key error with query_name fixed