fixing appending and printing