save function not working