added error handling for too-short reads