contract SpendableWallet is Ownable {
    ERC20 public token;

    event ClaimedTokens(
        address indexed _token,
        address indexed _controller,
        uint256 _amount
    );

    constructor(address _token, address _owner) public {
        token = ERC20(_token);
        owner = _owner;
    }

    function spend(address _to, uint256 _amount) public onlyOwner {
        token.transfer(_to, _amount);
    }

    /// @notice This method can be used by the controller to extract mistakenly
    ///  sent tokens to this contract.
    /// @param _token The address of the token contract that you want to recover
    ///  set to 0 in case you want to extract ether.
    function claimTokens(address _token) public onlyOwner {
        if (_token == 0x0) {
            owner.transfer(address(this).balance);
            return;
        }

        ERC20 erc20token = ERC20(_token);
        uint256 balance = erc20token.balanceOf(address(this));
        erc20token.transfer(owner, balance);
        emit ClaimedTokens(_token, owner, balance);
    }
}
function claimTokens(address _token) public onlyOwner {
    if (_token == 0x0) {
        owner.transfer(address(this).balance);
        return;
    }

    ERC20 erc20token = ERC20(_token);
    uint256 balance = erc20token.balanceOf(address(this));
    erc20token.transfer(owner, balance);
    emit ClaimedTokens(_token, owner, balance);
}

/// @notice This method can be used by the controller to extract mistakenly
///  sent tokens to this contract.
/// @param _token The address of the token contract that you want to recover
///  set to 0 in case you want to extract ether.