fixed free memory error