using author's method to replace mine to fix Leak