updated pop and shift