```currentPos``` is only used on line 189, which is executed only if ```doc``` is available. The variable could be declared here and initialized inside the ```if(doc)```. No need for it to have a value otherwise.