extract method on redundant code