fixed bugs for the non-ARC version