Refactor form_user functionality