Updated the code to be JSHint-compliant