Create more general checkString function