connect#callback code cleanup