created class search function and optimized it.