refactoring sideeffect fixed