Added panic handling