update queue and stack