on save function not working