fixed an issue which could cause a NullReference exception