extract duplicated code into UpdateVersionsInFile function