Refactor parallel implementation