Factor out common front end code