speed up and empty line bug fix