improve saving to storage functionality