change 'if' to 'elseif'

else we add l_i and l_j, and then remove them immediately