use promises in saving code