Refactoring functions about append and connect.