refactored with regards to single responsibility