Fixed panic() function to work properly