fixed bug caused by setting parent in the wrong place