refactored to make almost all calls async