Fixing wrong function in 'count' optimizer