markRow function rewritten