Improve clear cache function
Thanks to @HVSoftware