fixed bad assumption about query result order
adding columns to database for response processing