refactor the whole application with promise