add function delay and defer