initial rules engine code