add sleep to make sure flush happens