change direct stdout to return data and add lib support