Modified the writes and added stack functionality