fixes issues with the tmp file getting removed to early