This code does not crash the page no more, however, now the search is never ending. I mean, it keeps “searching”, the “load icon” keeps spinning and never shows any results. So in essence it “hangs” on something.
Do you want access to my site so you can see the problem first hand? That might e easier to troubleshoot.