how do I automatically create rows based on certain rules