Refactor promise structure in connect