added saving to file (still needs repair)