Add extra check to ensure gallery exists before trying to check its password.