Refactoring the code of check_versions.py