added code to randomly place 0 if no rule found.