fix for Cannot call method 'getTime' of null