turning this into something not horrible looking

also adds handlers to the connected state