Added promise module
Refactored to using promises