Added and implemented saving function.