slight optimization in SQ code