Converted to using promises and added doc