improve done condition