Implemented countdown function

@afeld Please review and merge when ready.