preparing numbers, simplification of code, ensuring rows are distinct