Refactor the upstream