updated the remove function to pop the item out