Refactor how to get singleton class