Promise-ified the script, to prevent callback pyramids of death