add a if clause that determines whether the remainder is 0 to draw dashed line.