Added code for delay functionality.