Implemented more robust saving mechanism