checking direction a—>b instead of assuming it