fixed the stack issues with the new code