Fixes potential memory leak