added a organizeChildren function to reorganize stage children