Fix the bug in the logic of Cell Template

This bug happens when the page size is smaller that the total columns... it is just a simple coding mistake.