fixed memory issues, compare works well -MM