move kill_middleman to a function so it actually works