Fix nonce calculation