Fixing the double free error