fix link duplication issue
Better memory managment