refactor to reduce servlet redundancies