Declare var selectionPosition somewhere unless it is supposed to be global.