function invest(address _to, uint256 _amount) canReleaseToken onlyRewardManager public returns (bool success) {
            
            require((_to != 0) && (_to != address(this)));

            bool IsTransferAllowed = false;

            if(IsPreSaleEnabled){
                require(preSaleTokenBalances >= _amount);
                IsTransferAllowed = true;
                preSaleTokenBalances = preSaleTokenBalances - _amount;

                return true;
            }
            else if(IsSaleEnabled){
                IsTransferAllowed = true;
            }
            else{
                revert();
            }

            require(IsTransferAllowed);
            var previousBalanceFrom = balanceOfAt(msg.sender, block.number);
            require(previousBalanceFrom >= _amount);
            updateValueAtNow(balances[msg.sender], previousBalanceFrom - _amount);

            var previousBalanceTo = balanceOfAt(_to, block.number);
            require(previousBalanceTo + _amount >= previousBalanceTo);
            updateValueAtNow(balances[_to], previousBalanceTo + _amount);

            if(msg.sender == rewardManager){
                transferFrom(owner, _to, _amount);      
            }
            else{
                transferFrom(msg.sender, _to, _amount); 
            }
        }