changed funct names, added CSV write