fix some issues in the pull_key funtions