Implementation of delay()