Updated code to stick to JSHint recommandations