changed where the clear_lines function are called