Adding rules engine code