refactored clear_line