refactor handlers to match http package, functions that return handlers