fix heap bug