fix bug in factorization of CSV code... need to rethink it at some point