Updated version of the script to help with cache