Try to fix error by checking if class exists before tryin filename