Extracted serial connection operations to a function