Refactor nonce reading