Refactored from async to promises.