calculating perimeter
working code with equality checks