fixed how query result is passed