Refactored row-end checker