fixing throwing of exception