timer instead of loop with rate::sleep