add sleep loop to implement period.