Fixed build broken by b0fd0bdf657365125f1a96fa55195cedfc10ab24

Not tested for performance, but seems like code is the same as was meant in the original commit a0691788d4cc882de7bbaeb8300ba8bbf37b3ed0 by @espindola. I'll kindly appreciate if @vargaz review my fix.