Refeactoring code