fixing possible memory over-release