function finalize() external onlyOwner {
        require(!isFinalized);
        require(block.timestamp > endTime || sold >= cap);
        token.transfer(wallet, token.balanceOf(this));
        wallet.transfer(address(this).balance);
        emit Finalized();
        isFinalized = true;
    }