added better auto count mechanism