Refactor version control logic