changed to class structure and added command-line flags