Extract function as a method