Refactor script to countdown