I have the function below which I found and have modified to suit my needs and fit into my wrapper class. The only issue I have with it is it exceeds the memory limit of my