Consider implementing task-based async pattern for this.