Search algo similar to dmenu, fix crash.