Fix traceback when  is not valid