Bug fix in checking for returned sql data 1