implemented save to work correctly