fix problem with thread
fix problem with server thread
add input from cli