Check if next sibling exists before referencing it