slighty faster and reusable string matching