memory fix in sample