Fix issue with result

Now uses result of query to fix compile error,