refactored countdown function structure