implemented grouping, added guards, wrote some specs