Refactor set_version