Fixing save function