Refactor javascript no errors JSlint