reduce mechanism_template socket code