refine func, move the ListenAndServe to server.