fixed i variable is out of scope
exception replaced with runtime_error, exceptions constructor doesnt take parameters
fixed warning: initialized and declared extern