listen and connect moved to functions to save space