fixed bug with free and added merge