Working file, but calling main creates two instances