added buffered output - need to test