Added logic to add rules and write to disk