implemt parsing of group option, refactor some code