[IMP]mail: Improve code to avoid traceback for Application wise search