updated to bluebird chains and fixed code to match