Refactor connect module