Refactor add-key.sh