Fix port_index error when number is passed