Optimized a loop and fixed a naming bug

changed two lines from self.children to self.Children
moved a function out of a loop, so we just loop on the result now