move request handling into separate file