added some comments and check to remove wms layer when added