fixing seg fault due to incorrect mpos writing beyond all_count array