first implamentation fo a stack for creating the hirarchy