save function is now working