Refactored js and fixed password field