fix the bug of counting wrong due to object