fix bug for query without any results