fixes localStorage flag bug
refactored to requirejs plugin