minor js code refactorings