contract StandardToken is ERC20, Ownable, SafeMath {

    /**
     * Mapping from addresses of token holders to the numbers of tokens belonging
     * to these token holders.
     */
    mapping (address => uint256) balances;

    /**
     * Mapping from addresses of token holders to the mapping of addresses of
     * spenders to the allowances set by these token holders to these spenders.
     */
    mapping (address => mapping (address => uint256)) allowed;

    /**
     * Create new Standard Token contract.
     */
    function StandardToken() {
      // Do nothing
    }

    /**
     * Get number of tokens currently belonging to given owner.
     *
     * @param _owner address to get number of tokens currently belonging to the
     *        owner of
     * @return number of tokens currently belonging to the owner of given address
     */
    function balanceOf(address _owner) constant returns (uint256 balance) {
        return balances[_owner];
    }

    /**
     * Transfer given number of tokens from message sender to given recipient.
     *
     * @param _to address to transfer tokens to the owner of
     * @param _amount number of tokens to transfer to the owner of given address
     * @return true if tokens were transferred successfully, false otherwise
     */
    function transfer(address _to, uint256 _amount) returns (bool success) {
        // avoid wasting gas on 0 token transfers
        if(_amount <= 0) return false;
        if (msg.sender == _to) return false;
        if (balances[msg.sender] < _amount) return false;
        if (balances[_to] + _amount > balances[_to]) {
            balances[msg.sender] = safeSub(balances[msg.sender],_amount);
            balances[_to] = safeAdd(balances[_to],_amount);
            Transfer(msg.sender, _to, _amount);
            return true;
        }
        return false;
    }

    /**
     * Transfer given number of tokens from given owner to given recipient.
     *
     * @param _from address to transfer tokens from the owner of
     * @param _to address to transfer tokens to the owner of
     * @param _amount number of tokens to transfer from given owner to given
     *        recipient
     * @return true if tokens were transferred successfully, false otherwise
     */
    function transferFrom(address _from, address _to, uint256 _amount) returns (bool success) {
        // avoid wasting gas on 0 token transfers
        if(_amount <= 0) return false;
        if(_from == _to) return false;
        if (balances[_from] < _amount) return false;
        if (_amount > allowed[_from][msg.sender]) return false;

        balances[_from] = safeSub(balances[_from],_amount);
        allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender],_amount);
        balances[_to] = safeAdd(balances[_to],_amount);
        Transfer(_from, _to, _amount);

        return false;
    }

    /**
     * Allow given spender to transfer given number of tokens from message sender.
     *
     * @param _spender address to allow the owner of to transfer tokens from
     *        message sender
     * @param _amount number of tokens to allow to transfer
     * @return true if token transfer was successfully approved, false otherwise
     */
    function approve(address _spender, uint256 _amount) returns (bool success) {

        // To change the approve amount you first have to reduce the addresses`
        //  allowance to zero by calling `approve(_spender, 0)` if it is not
        //  already 0 to mitigate the race condition described here:
        //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
        if ((_amount != 0) && (allowed[msg.sender][_spender] != 0)) {
           return false;
        }
        if (balances[msg.sender] < _amount) {
            return false;
        }
        allowed[msg.sender][_spender] = _amount;
        Approval(msg.sender, _spender, _amount);
        return true;
     }

    /**
     * Tell how many tokens given spender is currently allowed to transfer from
     * given owner.
     *
     * @param _owner address to get number of tokens allowed to be transferred
     *        from the owner of
     * @param _spender address to get number of tokens allowed to be transferred
     *        by the owner of
     * @return number of tokens given spender is currently allowed to transfer
     *         from given owner
     */
     function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
       return allowed[_owner][_spender];
     }
}
/**
 * Standard Token Smart Contract that could be used as a base contract for
 * ERC-20 token contracts.
 */
function transfer(address _to, uint256 _amount) returns (bool success) {
    // avoid wasting gas on 0 token transfers
    if(_amount <= 0) return false;
    if (msg.sender == _to) return false;
    if (balances[msg.sender] < _amount) return false;
    if (balances[_to] + _amount > balances[_to]) {
        balances[msg.sender] = safeSub(balances[msg.sender],_amount);
        balances[_to] = safeAdd(balances[_to],_amount);
        Transfer(msg.sender, _to, _amount);
        return true;
    }
    return false;
}

/**
 * Transfer given number of tokens from message sender to given recipient.
 *
 * @param _to address to transfer tokens to the owner of
 * @param _amount number of tokens to transfer to the owner of given address
 * @return true if tokens were transferred successfully, false otherwise
 */