Changes to strcutue and save algorithem