Refactored to promises.