speed up startsWith and endsWith by using string.sub instead of string.find