rewrite function delay_func