removed more foreach(function) for garbage collection