- Finished optimise memory function