Refactor collect_artifacts