Updated code using CallbackStack