move from callbacks on main lib to promises with when module.