removed system.exit and replaced with throws exception. Lot of functions now throw.