Refactor for usage with servlet engine