Reformatting the query