refactored the code in displaying cases but now with a problem with
pagination