Some modification in save function