Added j!=k and a fast variant