added logic to rules