Extract redundant code to method