Refactoring the credential importing