made writegrp a bit more automatic