modify fuction getDistance

Combine same return statement.