correct logic control
doc + token generation