Use the promises api correctly