Refactored code from static class