re-organize functions for auth use