Why does this need to happen in the constructor rather than onConnect?