Move code from hapi