max count improved, added offset