added baseline distance calculation