added reformat_query