replace pyramids of doom with async