Added Exception Handling and Cosmetic Changes

Added Exception Handling and Cosmetic Changes