Extracted the credential-fn

Extracted the credential-fn so we can see what it is doing