split delay into library code