compelte client
add debug print and remove bug in sprintf