refactored to use CSV library