fix angle distance function