Extract long code as a method