working code before leafletintegration