Extracted sendCommand and sendFunction