Added logic for rules 1 thru 4