implements queue and stack