Adjusted onTick.
added quantity function.