move check version to a function