javascript refactors