simplify by making a switch out of a 'if'
plug memory leak when failing to load snap