delay: fixed off-by-one in millisecond delay and changed to upcounting