Add ternary statement to the createInstance method