fixed problem with duplicate output