csv option added, refactoring