First thing first ,
1- move the export and simple display functionality into 2 different methods.
2- Create a Client Object exactly once by using Singleton Pattern.
solved How to remove duplicate code if I create array with different number of elements? [closed]