working for 3 result sets..testing remains to be done for large n result sets