refactored save and load handling