Fix before saving function