trying to update counting function