improved input validation (port)