mostly finished, file output needs working on