added some missing semi-colons and replaced some 'undefined' for 'null'.