Added erode and dilate to remove noise