Quick fix preventing errors on page refresh