move most code to host; not working yet