added the exception handling again