contract BasicToken {
  using SafeMath for uint256;

  mapping(address => uint256) balances;

  uint256 totalSupply_;

  /**
  * @dev total number of tokens in existence
  */
  function totalSupply() public view returns (uint256) {
    return totalSupply_;
  }
  

  event Transfer(address indexed from, address indexed to, uint256 value);
  /**
  * @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, uint _value) public returns (bool) {
    require(_to != address(0));
    require(_value <= balances[msg.sender]);
    
    // SafeMath.sub will throw if there is not enough balance.
    if(!isContract(_to)){
    balances[msg.sender] = balances[msg.sender].sub(_value);
    balances[_to] = balances[_to].add(_value);
    Transfer(msg.sender, _to, _value);
    return true;}
    else{
        balances[msg.sender] = balanceOf(msg.sender).sub(_value);
    balances[_to] = balanceOf(_to).add(_value);
    VTKReceiver receiver = VTKReceiver(_to);
    receiver.VTKFallback(msg.sender, _value, 0);
    Transfer(msg.sender, _to, _value);
        return true;
    }
    
  }

  /**
  * @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 view returns (uint256 balance) {
    return balances[_owner];
  }


function isContract(address _addr) private 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);
  }


  //function that is called when transaction target is a contract
  //Only used for recycling VTKs
  function transferToContract(address _to, uint _value, uint _code) public returns (bool success) {
    require(isContract(_to));
    require(_value <= balances[msg.sender]);
  
      balances[msg.sender] = balanceOf(msg.sender).sub(_value);
    balances[_to] = balanceOf(_to).add(_value);
    VTKReceiver receiver = VTKReceiver(_to);
    receiver.VTKFallback(msg.sender, _value, _code);
    Transfer(msg.sender, _to, _value);
    
    return true;
  }
  
}
function transfer(address _to, uint _value) public returns (bool) {
  require(_to != address(0));
  require(_value <= balances[msg.sender]);
    
  // SafeMath.sub will throw if there is not enough balance.
  if(!isContract(_to)){
  balances[msg.sender] = balances[msg.sender].sub(_value);
  balances[_to] = balances[_to].add(_value);
  Transfer(msg.sender, _to, _value);
  return true;}
  else{
      balances[msg.sender] = balanceOf(msg.sender).sub(_value);
  balances[_to] = balanceOf(_to).add(_value);
  VTKReceiver receiver = VTKReceiver(_to);
  receiver.VTKFallback(msg.sender, _value, 0);
  Transfer(msg.sender, _to, _value);
      return true;
  }
    
}

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