small optimization in apply