Use a function to remove rests.