move code from hapi