fixed countdown function