My attempt to remove the two if

I'm not sure that this solution works, but the test is green ;-)