Slightly changed code for compliance with jsHint