Blocked at trying to incorporate time thread in while loop