freeing states before freeing states content is wrong