added stack size calculation