cleaned up code, refined fileio