Refactored to promise api