added proper ip routing semantics. quite inefficient