changed length to length(unique)