function sale(address beneficiary, uint256 value, address referrer) internal {
        require(crowdsaleOpen());
        require(value > 0);
        collectedEther = collectedEther.add(value);
        contributions[beneficiary] = contributions[beneficiary].add(value);
        uint256 amount;
        if(referrer == address(0)){
            amount = getTokensWithBonuses(value, false);
        } else{
            amount = getTokensWithBonuses(value, true);
            uint256 referrerAmount  = getReferrerBonus(value);
            tokensSold = tokensSold.add(referrerAmount);
            mintTokens(referrer, referrerAmount);
        }
        tokensSold = tokensSold.add(amount);
        mintTokens(beneficiary, amount);
    }