Refactor for Credentials gem