fixes potential crashes