Refactored all procs to use stack