Change API from callback to promise