better technique for flushing output