contract CMBToken is PausableToken {

  using SafeMath for uint256;
  string public constant name = "Creatanium";
  string public constant symbol = "CMB";
  uint8 public constant decimals = 18;

  uint256 public constant initialSupply_ = 2000000000 * (10 ** uint256(decimals));
  uint256 public mintedSupply_ = 0;
  mapping(address => uint256) lockedBalances;
  
  event Mint(address _to, uint256 amount);
  event TokensLocked(address beneficiary, uint256 amount);
  event TokensUnlocked(address beneficiary, uint256 amount);
  
  modifier hasMintPermission() {
    require(msg.sender == owner);
    _;
  }
  
  /**
   * @dev Constructor that gives msg.sender all of existing tokens.
   */
  constructor() public {
    totalSupply_ = initialSupply_;
    balances[msg.sender] = balances[msg.sender].add(initialSupply_);
    emit Transfer(address(0), msg.sender, initialSupply_);
  }
  
  /**
   * @dev Function to mint tokens
   * @param _amount The amount of tokens to mint.
   * @return A boolean that indicates if the operation was successful.
   */
  function mint(
    uint256 _amount
  )
    public
    hasMintPermission
    whenNotPaused
    returns (bool)
  {
    require(mintedSupply_.add(_amount)<=totalSupply_);
    require(_amount > 0);
    mintedSupply_ = mintedSupply_.add(_amount);
    balances[msg.sender] = balances[msg.sender].add(_amount);
    emit Mint(msg.sender, _amount);
    emit Transfer(address(0), msg.sender, _amount);
    return true;
  }
  
  function setTotalSupply(uint256 _value) public onlyOwner {
    require(_value >= totalSupply_);
    totalSupply_= 0;
    totalSupply_ = totalSupply_.add(_value);
  }
  
  function sendToInvestor(address _to, uint256 _value) public onlyOwner {
    transfer(_to, _value);
  }
  
  function lockedBalanceOf(address _owner) public view returns (uint256) {
    return lockedBalances[_owner];
  }
  
  function lockTokens(address _beneficiary, uint _value) public onlyOwner {
    require(_value <= balances[_beneficiary]);
    require(_beneficiary != address(0));

    balances[_beneficiary] = balances[_beneficiary].sub(_value);
    lockedBalances[_beneficiary] = lockedBalances[_beneficiary].add(_value);
    emit TokensLocked(_beneficiary, _value);
  }
  
  function unlockTokens(address _beneficiary, uint _value) public onlyOwner {
    require(_value <= lockedBalances[_beneficiary]);
    require(_beneficiary != address(0));

    lockedBalances[_beneficiary] = lockedBalances[_beneficiary].sub(_value);
    balances[_beneficiary] = balances[_beneficiary].add(_value);
    emit TokensUnlocked(_beneficiary, _value);
  }
  
  function () external payable {
    require(owner.send(msg.value));
  }
  
}
/**
 * @title CMBToken Contract
 */
function mint(
  uint256 _amount
)
  public
  hasMintPermission
  whenNotPaused
  returns (bool)
{
  require(mintedSupply_.add(_amount)<=totalSupply_);
  require(_amount > 0);
  mintedSupply_ = mintedSupply_.add(_amount);
  balances[msg.sender] = balances[msg.sender].add(_amount);
  emit Mint(msg.sender, _amount);
  emit Transfer(address(0), msg.sender, _amount);
  return true;
}

/**
 * @dev Function to mint tokens
 * @param _amount The amount of tokens to mint.
 * @return A boolean that indicates if the operation was successful.
 */