added wait and improved line clearing