fix bug with handling exception