Implemented modify_cached() which reduced running time to 31%