a bit more refactoring to get all the cases