greatly improved the type matching by using regular expressions