Fixed and tested 'too many rows' error