Fix predictable ports bug

Added a method to check ports that are occupied by the gears
replace condition with 
if (Int32.TryParse(port, out occupiedport))