A working version but it has problems because it doesn't make any difference between tokens and ids