This is a global variable, and ought to be made local. Possibly by placing it on an object which is responsible for doing some of the calculations around rap length and how far it needs to move.