.js file for save function