updated line 56(@sides-1 to @sides)