fixed error format a bit
improved counting