refactored and annotated asynchronous i/o