add main class and use parameter for n
seems to work, check logic of if condition in main loop