There is already a module method that tells you if the format is available. See if you can use that method instread.