fix bug when query result is null