refactor document write into Document, kinda sloppily, and create a user profile on first sign-in