refactor singleton version