implemented Manhattan distance