Define method dynamically.