refacoring using objects