corrected check to use instanceof RegEx