Refactoring with singleton