My edit is actually fewer operations than the old way. The only reason there are more lines is because of the allman brace style and the comments I've added. The old way included redundancy and repetition, but neither were clear. Oldcache was always the same as cachedgraphics, and the condition for checking is the graphic has changed if done twice but with different vars.