finish stackandqueue