move time outside publish function