fixed memory management issues in comparison