Double free problem solved