now works with non-square input, also prints generations as they come along