Functioning trim, search, and matrix-based search code