tried to refactor, hoping CC score goes down