restructure group and user middleware