fixed bug in get_next_wire_direction