factory and auth boilerplate