fix for null pointer when saving