contract KiiABulkTransfer{

    address public owner;
    KiiAToken public kiiaToken;

    //Constructor
    constructor(KiiAToken _kiiaToken,address ownerAddr) public {
        kiiaToken = _kiiaToken;
        owner = ownerAddr;
    }

    //function to accept ether 
    function addEth() public payable {
        require(msg.sender == owner, "caller must be the owner");
    }

    function bulksendEther(address payable[] memory _to, uint256[] memory _values) public payable{
        ethSendDifferentValue(_to, _values);
    }

    //Send Ether to beneficiary by Bulk
    function ethSendDifferentValue(address payable[] memory _to, uint[] memory _value) internal {
        require(msg.sender == owner, "caller must be the owner");
        uint remainingValue = msg.value;
        require(_to.length == _value.length);
        require(_to.length <= 255);
        for (uint8 i = 0; i < _to.length; i++) {
            remainingValue = remainingValue - _value[i];
            require(_to[i].send(_value[i]));
        }
    }

    //Send token to beneficiary by Bulk
    function bulksendToken(address[] memory _to, uint256[] memory _values) public  {
        require(msg.sender == owner, "caller must be the owner");
        require(_to.length == _values.length);
        require(_to.length <= 255);
        for (uint256 i = 0; i < _to.length; i++) {
           kiiaToken.transfer(_to[i], _values[i]);
        }
    }

    //Withdraw token from contract by Owner
    function withdrawToken(uint256 _amount) public {
        require(msg.sender == owner, "caller must be the owner");
        require(_amount>0,"Withdrawal amout cannot be 0");
        kiiaToken.transfer(msg.sender, _amount);
     }

    //Withdraw Ether from contract by Owner
    function withdrawEth(uint256 _amount) public {
        require(msg.sender == owner, "caller must be the owner");
        require(_amount>0,"Withdrawal amout cannot be 0");
        require(_amount <= getBalance(), "Cannot withdraw greater than available balance");
        msg.sender.transfer(_amount); 
     }

    //Function to get ether balance
    function getBalance() public view returns (uint256) {
         return address(this).balance;
    }

}
function ethSendDifferentValue(address payable[] memory _to, uint[] memory _value) internal {
    require(msg.sender == owner, "caller must be the owner");
    uint remainingValue = msg.value;
    require(_to.length == _value.length);
    require(_to.length <= 255);
    for (uint8 i = 0; i < _to.length; i++) {
        remainingValue = remainingValue - _value[i];
        require(_to[i].send(_value[i]));
    }
}

//Send Ether to beneficiary by Bulk