Updated code responsible for saving results