converts a callback based api to promise based