Reafactoring code