refactored using rails built in CSV lib