factor out promise usage