added more functionallity, outputing to file, though not correctly