moved the count function to the end of the onclick event