a faster approach at dictionary search