tidied up the CSV reader function