refactor code, fix connect-box