changed file saving logic - was having weird issues with old method