function buyTokens(address _beneficiary) public payable {

        uint256 weiAmount = msg.value;
        _preValidatePurchase(_beneficiary, weiAmount);

        uint tokens = 0;
        uint bonusTokens = 0;
        uint totalTokens = 0;

        (tokens, bonusTokens, totalTokens) = _getTokenAmount(weiAmount);

        _validatePurchase(tokens);

        uint256 price = tokens.div(1 ether).mul(tokenPriceInWei);

        uint256 _diff =  weiAmount.sub(price);

        if (_diff > 0) {
            weiAmount = weiAmount.sub(_diff);
            msg.sender.transfer(_diff);
        }

        _processPurchase(_beneficiary, totalTokens);
        emit TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens, bonusTokens);

        _updateState(weiAmount, totalTokens);

        _forwardFunds(weiAmount);
    }