using promises to ensure correct request order