finish the viewed count function