update the implementation of frame and stack