replaced yield & block_given? inside define_method with explicit block parameter since the former does not work