Some changes with countPerimeter method