Fix implementation for k > 1