Fixed incorrect repeating of instructions in main