fix crash when clicking on layer