replaced queue variable names with stack