factored out common logic in clock.