Moved rules to code