reworked stack and removed old code