bug with multiple ports

Signed-off-by: Daniel A. Zorin <juan@lvk.cs.msu.su>