refactor to avoid authentication boilerplate