// Update is called once per frame
    void Update()
    {
        if (patternMaster.isPlaying())
        {
            List <MusicEvent> outOfRange = new List <MusicEvent> ();

            foreach (KeyValuePair <MusicEvent, GameObject> pair in musicEvents)
            {
                MusicEvent e        = pair.Key;
                GameObject pokeball = pair.Value;

                float delta = timeToDelta(e.startTime);
                float y     = timeToY(e.startTime);

                //if objects are past pad point
                if (delta < -ttl)
                {
                    outOfRange.Add(e);
                }

                //if objects are visible
                if (delta < scale)
                {
                    pokeball.transform.position = new Vector3(pokeball.transform.position.x, y, pokeball.transform.position.z);
                }
            }

            foreach (MusicEvent e in outOfRange)
            {
//				Destroy (musicEvents [e]);

//				removeMusicEvent (e);
//				GameObject musicEventObj = musicEvents [e];
                removeMusicEvent(e);
                releaseEvent(e);

                Messenger <MusicEvent> .Invoke(MessengerKeys.EVENT_OUT_OF_RANGE, e);
            }

            foreach (MusicEvent e in activeHolds.Keys)
            {
                bool      active = activeHolds [e];
                NoteTrail trail  = noteTrails [e];

                if (active)
                {
                    trail.setTopY(padList[0].transform.position.y);
                    trail.setBottomY(timeToY(e.endTime));
                }
                else
                {
                    trail.setTopY(timeToY(e.startTime));
                    trail.setBottomY(timeToY(e.endTime));

//					NoteTrail trail = noteTrails [laneForEvent (e)];
//					trail.setTopY (timeToY(e.startTime));
//					trail.setBottomY(timeToY(e.endTime));
                }
            }



//			foreach (MusicEvent e in activeHolds.K) {
//				NoteTrail trail = noteTrails [laneForEvent (e)];
//				trail.setTopY (timeToY(e.startTime));
//				trail.setBottomY(timeToY(e.endTime));
//			}

            //clean up
            foreach (GameObject obj in destoryQueue)
            {
//				Destroy (obj);
                arrowPool.Decommision(obj);
            }
            destoryQueue.Clear();


            //		foreach (var e in musicEvents) {
            //			long delta = e.startTime + patternMaster.startTime - timeMaster.GetTime ();
            //
        }
//		}
    }