did some refactoring to help with single responsibility.