added error checking for no records