function buyTokens(address beneficiary) public payable {
        require(beneficiary != address(0));
        require(validPurchase());

        uint256 weiAmount = msg.value;

        require(weiAmount>500000000000000000);

        
        uint256 tokens = weiAmount.mul(getRate());

        
        weiRaised = weiRaised.add(weiAmount);

        
        token.issue(address(vault), tokens);

        
        vault.deposit(beneficiary, tokens, msg.value);

         TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);

        
        forwardFunds();
    }