refactoring credential checking and javascript files