improved time remaining function