refactored generateNewVersion function