fix bug in case of error