Added token generation and validation