code builds but hangs while running - C#