v2

more logic added to main server thread