Implemented last cell rule.