Make main functions return promises