Exception Handling

Added some exception handling to make the program run more gracefully