Changes query structure