contract BasicToken is ERC20Basic {
  using SafeMath for uint256;
 
  mapping(address => uint256) balances;
  
  modifier onlyPayloadSize(uint size) {
      require(!(msg.data.length < size + 4));
      _;
  }
 
  /**
  * @dev transfer token for a specified address
  * @param _to The address to transfer to.
  * @param _value The amount to be transferred.
  */
  function transfer(address _to, uint256 _value) public onlyPayloadSize(2*32) returns (bool) {
    bool result = _transfer(msg.sender, _to, _value);
    if (result && isContract(_to)) {
        result = _transferToContract(msg.sender, _to, _value);
    }
    return result;
  }
  
  function _transfer(address _from, address _to, uint256 _value) internal returns (bool) {
    require(_to != address(0));
    require(_value > 0);
    require(_value <= balances[_from]); 
    // SafeMath.sub will throw if there is not enough balance. 
    balances[_from] = balances[_from].sub(_value); 
    balances[_to] = balances[_to].add(_value); 
    emit Transfer(_from, _to, _value); 
    return true; 
  }
  
  //assemble the given address bytecode. If bytecode exists then the _addr is a contract.
  function isContract(address _addr) internal constant returns (bool is_contract) {
    uint length;
    assembly {
        //retrieve the size of the code on target address, this needs assembly
        length := extcodesize(_addr)
    }
    return (length > 0);
  }
  
  /**
    * @dev Function that is called when a user or another contract wants
    *  to transfer funds to smart-contract
    * @return A boolean that indicates if the operation was successful
    */
    function _transferToContract(address _from, address _to, uint _value) internal returns (bool success) {
        TokenReceiver receiver = TokenReceiver(_to);
        return receiver.tokenFallback(_from, this, _value);
    }
 
  /** 
   * @dev Gets the balance of the specified address. 
   * @param _owner The address to query the the balance of. 
   * @return An uint256 representing the amount owned by the passed address. 
   */ 
  function balanceOf(address _owner) public constant returns (uint256 balance) { 
    return balances[_owner]; 
  } 
}
/**
 * @title Basic token
 * @dev Basic version of StandardToken, with no allowances.
 * @dev Addedd ERC223 send tokens to another contract Implementation
 */
function transfer(address _to, uint256 _value) public onlyPayloadSize(2*32) returns (bool) {
  bool result = _transfer(msg.sender, _to, _value);
  if (result && isContract(_to)) {
      result = _transferToContract(msg.sender, _to, _value);
  }
  return result;
}

/**
 * @dev transfer token for a specified address
 * @param _to The address to transfer to.
 * @param _value The amount to be transferred.
 */