changed algorithm to follow server time instead of client time.