fix and improve version checking