implementing parent child structure between functions