added type checking for ports (input/output)