placed queries in wrong place