I'm leaving the query in the loop because we modify which elements have the sticky class within the loop.

Thanks for the last-child suggestion, I totally forgot about that!