New more generic version