bug 1008: fixed query output from $res to $res1