Major refactoring for better design. SRP