refactored to use async, but doesn't have access to index variables