added erosion function