refactor credentialstore