better validation for adding layers.