cleaner timeout code