fix bug in delay