some optimizations related to scalar search script