Small refactoring
Adding graceful error handling for invalid distance units