refacotor code