adding freeing resources