refactor getInstance method to instance define