Made line clearing more dynamic