fix NULL object access which strangely sometimes happens