using stack for modes