Improves the previous commit with a more complete coverage of the cases