fixing the query method to my will. formatting code