generalize handler to get better templating