intelligent function to get the cases