refactor code And update handle