bug fix. avoid NoneType exception