fix panic cases