refactor to external time parameter