Working version of the program, no output flag yet, group flag does nothing