better output and fix cert extraction