Making a more robust class snippet