refactored Delphi project to fix a bug in Rule 3
refactored C# code to fix a bug in Rule 3