adding data collection and error checking to set)rule function