refacting code