fixed bug with regexp
optimized search function