added function to emulate tree