Writing layers to database works from pop up window
fixing files