Refactor release code logic into another function