cleaned up code

starting work to write to tables instead of files