some refactoring, better version error message