Fixed bug when refreshing layer