properly writing output