Changed the extern and declaration of substring and errorMessage.