Question about removing vgui elements that have been already created

I am creating a menu with a list of items you can select from and when an item is clicked on the list, it shows a description / image of the item for sale. However after you click an item, if you click another item on the list, it draws the vgui elements over the previous ones and it just keeps doing it over and over as you select other items on the list.

So my question, is there a way to destroy or remove already created vgui elements? and if not how else could something like this be created? I cant seem to find anything to help with this. Thanks for any help in advanced.

panel:Remove() ?



[ERROR] gamemodes/beta/gamemode/shopmenu.lua:76: attempt to call method 'Remove' (a nil value)


I tried this but it wasn’t working for me. Can I get a small snippet of how panel:Remove() is intended to be used? Can even be pseudocode, just need an idea.

[lua]newPanel = vgui.Create(“DPanel”)
newPanel:SetSize(100,100)
newPanel:Center()

function removePanel()
if newPanel and newPanel:IsValid() then newPanel:Remove() end
end
concommand.Add(“remove_the_panel”,removePanel)[/lua]

The function removing the vgui element must have access to it, so generally the main panel everything parents to is global and the rest are local.