Final save funtion