add sendFragment API and refactor code