fixing bugs in delay implementation