Added error handling for layers without popups