some semblence of token matching and an improved matchOptions function