Add defer function for defer execution