diff --git a/src/com/mirantis/mk/Common.groovy b/src/com/mirantis/mk/Common.groovy
index 1aa6732..15676a9 100644
--- a/src/com/mirantis/mk/Common.groovy
+++ b/src/com/mirantis/mk/Common.groovy
@@ -55,30 +55,43 @@
 }
 
 /**
+ *
+ * Find credentials by ID
+ *
+ * @param credsId    Credentials ID
+ * @param credsType  Credentials type (optional)
+ *
+ */
+def getCredentialsById(String credsId, String credsType = 'any') {
+    def credClasses = [ // ordered by class name
+        sshKey:     com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey.class,
+        cert:       com.cloudbees.plugins.credentials.common.CertificateCredentials.class,
+        password:   com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials.class,
+        any:        com.cloudbees.plugins.credentials.impl.BaseStandardCredentials.class,
+        dockerCert: org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials.class,
+        file:       org.jenkinsci.plugins.plaincredentials.FileCredentials.class,
+        string:     org.jenkinsci.plugins.plaincredentials.StringCredentials.class,
+    ]
+    return com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
+        credClasses[credsType],
+        jenkins.model.Jenkins.instance
+    ).findAll {cred -> cred.id == credsId}[0]
+}
+
+/**
  * Get credentials from store
  *
  * @param id    Credentials name
  */
 def getCredentials(id, cred_type = "username_password") {
-    def credClass;
-    if(cred_type == "username_password"){
-        credClass = com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials.class
-    }else if(cred_type == "key"){
-        credClass = com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey.class
-    }
-    def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
-                    credClass,
-                    jenkins.model.Jenkins.instance
-                )
+    warningMsg('You are using obsolete function. Please switch to use `getCredentialsById()`')
 
-    for (Iterator<String> credsIter = creds.iterator(); credsIter.hasNext();) {
-        c = credsIter.next();
-        if ( c.id == id ) {
-            return c;
-        }
-    }
+    type_map = [
+        username_password: 'password',
+        key:               'sshKey',
+    ]
 
-    throw new Exception("Could not find credentials for ID ${id}")
+    return getCredentialsById(id, type_map[cred_type])
 }
 
 /**
@@ -258,19 +271,7 @@
  * @param id    Credentials name
  */
 def getPasswordCredentials(id) {
-    def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
-                    com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials.class,
-                    jenkins.model.Jenkins.instance
-                )
-
-    for (Iterator<String> credsIter = creds.iterator(); credsIter.hasNext();) {
-        c = credsIter.next();
-        if ( c.id == id ) {
-            return c;
-        }
-    }
-
-    throw new Exception("Could not find credentials for ID ${id}")
+    return getCredentialsById(id, 'password')
 }
 
 /**
@@ -279,19 +280,7 @@
  * @param id    Credentials name
  */
 def getSshCredentials(id) {
-    def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
-                    com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
-                    jenkins.model.Jenkins.instance
-                )
-
-    for (Iterator<String> credsIter = creds.iterator(); credsIter.hasNext();) {
-        c = credsIter.next();
-        if ( c.id == id ) {
-            return c;
-        }
-    }
-
-    throw new Exception("Could not find credentials for ID ${id}")
+    return getCredentialsById(id, 'sshKey')
 }
 
 /**
