improvements in computation, function to write params to file