Refactor javascript varibles