Extract same code to method.