Code refactoring to use promises instead of nested callbacks.
Code refactoring to use promises instead of nested callbacks.