added BSD license
replaced Number.isNaN with isNaN