add '!' to $index < count($functions)
refs #1544 debug