Made changes to get_instance method

Removed recursive portion of the method to prevent stack overflow.