calculate remaining time