Make library async by using Promises