put loop in server code