Factorised some ressource releasing