Make version checking more robust