this logic should be refactored & extracted to separate class with own test coverage. Now its easy to make mistake here because its not readable